home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksconfig.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  8.6 KB  |  294 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 1997 David Sweet <dsweet@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef KDELIBS_KSCONFIG_H
  19. #define KDELIBS_KSCONFIG_H
  20.  
  21. #include <qwidget.h>
  22. #include <qstring.h>
  23. #include <qstringlist.h>
  24.  
  25. #include <kdelibs_export.h>
  26.  
  27. class QCheckBox;
  28. class QComboBox;
  29. class QLabel;
  30.  
  31. class KConfig;
  32. class KSpellConfigPrivate;
  33.  
  34. /**
  35.  * @brief Encoding for the spell checker
  36.  * @note In the identifier names LATIN means ISO-8859, not ECMA Latin
  37.  * @todo Should be replaced by the charset strings
  38.  * because the config file would be more stable 
  39.  * when inserting entries in the list
  40.  */
  41. enum Encoding {
  42.   KS_E_ASCII=0,
  43.   KS_E_LATIN1=1, 
  44.   KS_E_LATIN2=2,
  45.   KS_E_LATIN3=3,
  46.   KS_E_LATIN4=4,
  47.   KS_E_LATIN5=5, ///< ISO-8859-5 (Cyrillic)
  48.   KS_E_LATIN7=6, ///< ISO-8859-6 (Arabic)
  49.   KS_E_LATIN8=7, ///< ISO-8859-7 (Greek)
  50.   KS_E_LATIN9=8, ///< ISO-8859-8 (Hebrew)
  51.   KS_E_LATIN13=9, ///< ISO-8859-13 (Latin 7)
  52.   KS_E_LATIN15=10, ///< ISO-8859-15 (Latin 9)
  53.   KS_E_UTF8=11,
  54.   KS_E_KOI8R=12,
  55.   KS_E_KOI8U=13,
  56.   KS_E_CP1251=14,
  57.   KS_E_CP1255=15
  58. };
  59.  
  60. enum KSpellClients {
  61.   KS_CLIENT_ISPELL=0,
  62.   KS_CLIENT_ASPELL=1,
  63.   KS_CLIENT_HSPELL=2,
  64.   KS_CLIENT_ZEMBEREK=3
  65. };
  66.  
  67. /**
  68.  * A configuration class/dialog for KSpell.
  69.  *
  70.  * It contains all of the options settings.The options are set to default
  71.  * values by the constructor and can be reset either by using the
  72.  * public interface or by using KSpellConfig as a widget in a dialog
  73.  * (or, preferably a tabbed dialog using KDialogBase) and letting
  74.  * the user change the settings. This way an application that uses
  75.  * KSpell can either rely on the default settings (in the simplest
  76.  * case), offer a dialog to configure KSpell, or offer a dialog to
  77.  * configure KSpell <em>for this app only</em> (in which case, the application
  78.  * should save the settings for use next time it is run).
  79.  * This last option might be useful in an email program, for example, where
  80.  * people may be writing in a language different from that used for
  81.  * writing papers in their word processor.
  82.  *
  83.  * @author David Sweet <dsweet@kde.org>
  84.  * @see KSpell
  85.  */
  86.  
  87. class KDEUI_EXPORT KSpellConfig : public QWidget
  88. {
  89.   Q_OBJECT
  90.  
  91.   public:
  92.     /**
  93.      * Constructs a KSpellConfig with default or custom settings.
  94.      *
  95.      * @param parent Parent of the widget.
  96.      * @param name Widget name.
  97.      * @param spellConfig Predefined configuration. If this parameter
  98.      *        is 0, a default configuration will be used.
  99.      * @param addHelpButton Enabled or hides a help button. See
  100.      * activateHelp for more information.
  101.      *
  102.      */
  103.     KSpellConfig( QWidget *parent=0, const char *name=0,
  104.           KSpellConfig *spellConfig=0, bool addHelpButton = true );
  105.  
  106.     KSpellConfig( const KSpellConfig & );
  107.  
  108.     /**
  109.      * Deconstructor.
  110.      * Deletes private class.
  111.      */
  112.     virtual ~KSpellConfig();
  113.  
  114.     void operator=( const KSpellConfig &ksc );
  115.  
  116.     /**
  117.      *
  118.      * @short Get the translated dictionary names and, optionally, the 
  119.      * corresponding internal dictionary names.
  120.      *
  121.      * Fills @p box with the human readable, translated dictionary names and
  122.      * selects the currently used dictionary (this will be the global 
  123.      * dictionary if you call @ref fillDicts directly after the constructor).
  124.      * If @p dictionaries isn't 0 then @p dictionaries will be filled with the
  125.      * corresponding internal dictionary names that are necessary to set the
  126.      * dictionary with @ref setDictionary.
  127.      *
  128.      * @param box Will be filled with the translated dictionary names.
  129.      * @param dictionaries Will be filled with the internal dictionary names.
  130.      *
  131.      * @since 3.2
  132.      *
  133.      */
  134.     void fillDicts( QComboBox* box, QStringList* dictionaries = 0 );
  135.  
  136.     /**
  137.      * @sect Options setting routines.
  138.      **/
  139.  
  140.     /**
  141.      *
  142.      * The @p _ignorelist contains words you'd like KSpell
  143.      * to ignore when it is spellchecking.  When you get a KSpellConfig
  144.      * object back from KSpell (using KSpell::kcConfig()),
  145.      * the @p _ignorelist contains whatever was put in by you plus
  146.      * any words the user has chosen to ignore via the dialog box.
  147.      * It may be useful to save this list with the document being
  148.      * edited to facilitate quicker future spellchecking.
  149.      */
  150.     void setIgnoreList( QStringList _ignorelist );
  151.  
  152.     /**
  153.      * The @p _replaceAllList contains word you like that replace
  154.      * word. Be careful that this list contains word which is replaced
  155.      * and new word.
  156.      */
  157.     void setReplaceAllList( QStringList _replaceAllList );
  158.  
  159.     /**
  160.      * Set an ISpell option.
  161.      *
  162.      * If @p true, don't create root-affix combinations.
  163.      */
  164.     void setNoRootAffix( bool );
  165.  
  166.     /**
  167.      * Set an ISpell option.
  168.      *
  169.      * If @p true, treat run-together words a valid.
  170.      */
  171.     void setRunTogether( bool );
  172.  
  173.     /**
  174.      * Set the name of the dictionary to use.
  175.      */
  176.     void setDictionary( const QString qs );
  177.     void setDictFromList( bool dfl );
  178.     //void setPersonalDict (const char *s);
  179.  
  180.     /**
  181.      *
  182.      */
  183.     void setEncoding( int enctype );
  184.     void setClient( int client );
  185.  
  186.     /**
  187.      * Options reading routines.
  188.      */
  189.     bool noRootAffix() const;
  190.     bool runTogether() const;
  191.     const QString dictionary() const;
  192.     bool dictFromList() const;
  193.     //QString personalDict () const;
  194.     int encoding() const;
  195.     QStringList ignoreList() const;
  196.     QStringList replaceAllList() const;
  197.  
  198.     int client() const; ///< Spell checker client, see KSpellClients
  199.  
  200.     /**
  201.      * Call this method before this class is deleted  if you want
  202.      * the settings you have (or the user has) chosen to become the
  203.      * global, default settings.
  204.      */
  205.     bool writeGlobalSettings();
  206.  
  207.     bool readGlobalSettings();
  208.   protected:
  209.     void fillInDialog();
  210.  
  211.     /**
  212.      * This takes a dictionary file name and provides both a language
  213.      * abbreviation appropriate for the $LANG variable, and a
  214.      * human-readable name.
  215.      *
  216.      * It also truncates ".aff" at the end of fname.
  217.      *
  218.      * @param fname the dictionary name file (input)
  219.      * @param lname the language abbreviation, such as de for German (output)
  220.      * @param hname the human-readable name, such as Deutsch (output)
  221.      *
  222.      * @return true if <pre>lname.data()==$LANG</pre>
  223.      */
  224.     bool interpret( QString &fname, QString &lname, QString &hname );
  225.  
  226.  
  227.   public slots:
  228.     /**
  229.      * Use this function to activate the help information for this
  230.      * widget. The function is particulary useful if the help button is
  231.      * not displayed as specified by the constructor. Normally you want
  232.      * to hide the help button if this widget is embedded into a larger
  233.      * dialog box that has its own help button. See kedit
  234.      * (optiondialog.cpp) for an example
  235.      */
  236.     void activateHelp( void );
  237.  
  238.  
  239.   protected slots:
  240.     /**
  241.      * Invokes the help documentation for kspell
  242.      */ 
  243.     void sHelp();
  244.     //void sBrowseDict();
  245.     //void sBrowsePDict();
  246.     void sNoAff( bool );
  247.     void sRunTogether( bool );
  248.     void sDictionary( bool );
  249.     void sPathDictionary( bool );
  250.     void sSetDictionary( int );
  251.     void sChangeEncoding( int );
  252.     void sChangeClient( int );
  253.     //void textChanged1 (const char *);
  254.     //void textChanged2 (const char *);
  255.  
  256.   protected:
  257.     // The options
  258.     int enc;            // 1 ==> -Tlatin1
  259.     bool bnorootaffix;        // -m
  260.     bool bruntogether;        // -B
  261.     bool dictfromlist;
  262.     bool nodialog;
  263.     QString qsdict;        // -d [dict]
  264.     QString qspdict;        // -p [dict]
  265.     QStringList ignorelist;
  266.     enum {rdictlist=3, rencoding=4, rhelp=6};
  267.     KConfig *kc;
  268.     int iclient;            // defaults to ispell, may be aspell, too
  269.  
  270.     QCheckBox *cb1, *cb2;
  271.     //KLineEdit *kle1, *kle2;
  272.     //QButtonGroup *dictgroup;
  273.     //QRadioButton *dictlistbutton, *dicteditbutton;
  274.     QLabel *dictlist;
  275.     QComboBox *dictcombo, *encodingcombo, *clientcombo;
  276.     //QPushButton *browsebutton1;
  277.     QStringList langfnames;
  278.  
  279. signals:
  280.     void configChanged();
  281.  
  282. private:
  283.     KSpellConfigPrivate *d;
  284.     void getAvailDictsIspell();
  285.     void getAvailDictsAspell();
  286. };
  287.  
  288. #endif // KDELIBS_KSCONFIG_H
  289.  
  290.  
  291.  
  292.  
  293.  
  294.